package com.vainycos.lotterysearch.config;

import com.vainycos.lotterysearch.service.mail.JavaMailTemplate;
import com.vainycos.lotterysearch.service.mail.MailTemplate;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

import javax.annotation.Resource;

/**
 * @author: Vainycos
 * @description
 * @date: 2022/11/10 16:53
 */
@Configuration
@AutoConfigureAfter(MailSenderAutoConfiguration.class)
public class MailConfiguration {

    @Resource
    private JavaMailSender mailSender;

    @Resource
    private MailProperties mailProperties;

    @Bean
    public MailTemplate mailTemplate() {
        return new JavaMailTemplate(mailSender, mailProperties);
    }

}